package com.manlost.biz.baby.impl.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.manlost.biz.baby.impl.dao.interfaces.BabyDraftDAO;
import com.manlost.biz.baby.model.dataobject.BabyDraft;
import com.manlost.biz.common.ibatis.BaseSqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * 
 * @wqq 2012-03-26
 */
@Repository
public class BabyDraftDAOImpl extends BaseSqlMapClientDaoSupport implements BabyDraftDAO {

	/**
	 * 插入数据
	 * 
	 * @param manlostBaby
	 * @return 插入数据的主键
	 */
	public Long insertOne(BabyDraft babyDraft) {
		Object id = getSqlMapClientTemplate().insert("baby_draft.insert",
				babyDraft);
		return (Long) id;
	}

	/**
	 * 更新记录
	 * @param manlostBaby
	 * @return 受影响的行数
	 */
	public Integer updateOne(BabyDraft babyDraft) {
		int result = getSqlMapClientTemplate().update("baby_draft.update",
				babyDraft);
		return result;
	}

	/**
	 * 根据主键获取manlostBaby
	 * 
	 * @param id
	 * @return manlostBaby
	 */
	public BabyDraft findOneByPrimaryKey(Long id) {
		BabyDraft manlostBabyDO = (BabyDraft) getSqlMapClientTemplate()
				.queryForObject("baby_draft.findByPrimaryKey", id);
		return manlostBabyDO;
	}

	/**
	 * 删除记录
	 * 
	 * @param id
	 * @return 受影响的行数
	 */
	public Integer deleteOneByPrimaryKey(Long id) {
		Integer rows = (Integer) getSqlMapClientTemplate().delete(
				"baby_draft.deleteByPrimaryKey", id);
		return rows;
	}
	
	public Long insertBabyDrafts(List<BabyDraft> babyDrafts) {
		return getSqlMapClientTemplate().batchInsert("baby_draft.insert", babyDrafts);
	}
}